home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / qbfaqr01.zip / CURDIR.BAS < prev    next >
BASIC Source File  |  1992-08-10  |  2KB  |  64 lines

  1. 'Date: 05-27-92 (01:13)
  2. 'From: JOE NEGRON
  3. '------------------------------------------------------------------------
  4.  
  5. DEFINT A-Z
  6.  
  7. '$INCLUDE: 'QB.BI'
  8.  
  9. DECLARE FUNCTION GetDir$ (Drive$)
  10. DECLARE FUNCTION GetDrv$ ()
  11.  
  12. CurDrv$ = GetDrv$
  13. CurDir$ = GetDir$("")
  14.  
  15. PRINT "Current drive is " + CurDrv$
  16. PRINT "Current directory is " + CurDir$
  17.  
  18. END
  19.  
  20. '***********************************************************************
  21. '* FUNCTION GetDir$
  22. '*
  23. '* PURPOSE
  24. '*    Uses DOS ISR 21H, Function 47H (Get Current Directory) to retrieve
  25. '*    the current directory for the specified drive.  Drive$ may be null
  26. '*    to indicate the default drive.
  27. '*
  28. '* PARAMETER(S)
  29. '*    Drive$
  30. '***********************************************************************
  31. FUNCTION GetDir$ (Drive$) STATIC
  32.    DIM Temp AS STRING * 64
  33.  
  34.    InRegsX.ax = &H4700
  35.  
  36.    'must convert drive to integer
  37.    'current = 0, A: = 1, B: = 2, C: = 3, etc.
  38.    IF Drive$ > "" THEN
  39.       InRegsX.dx = ASC(UCASE$(Drive$)) - 64
  40.    ELSE
  41.       InRegsX.dx = 0
  42.    END IF
  43.  
  44.    InRegsX.ds = VARSEG(Temp$)
  45.    InRegsX.si = VARPTR(Temp$)
  46.  
  47.    InterruptX &H21, InRegsX, OutRegsX
  48.  
  49.    GetDir$ = "\" + LEFT$(Temp$, INSTR(Temp$, CHR$(0)) - 1)
  50. END FUNCTION
  51.  
  52. '***********************************************************************
  53. '* FUNCTION GetDrv$
  54. '*
  55. '* PURPOSE
  56. '*    Uses DOS ISR 21H, Function 19H (Get Current Disk) to return the
  57. '*    currently logged disk drive.
  58. '***********************************************************************
  59. FUNCTION GetDrv$ STATIC
  60.    InRegs.ax = &H1900
  61.    Interrupt &H21, InRegs, OutRegs
  62.    GetDrv$ = CHR$((OutRegs.ax AND &HFF) + 65) + ":"
  63. END FUNCTION
  64.